package com.abing.sandbox;

import com.abing.sandbox.config.CodeSandboxProperties;
import com.abing.sandbox.request.ExecuteCodeRequest;
import com.abing.sandbox.request.ExecuteCodeResponse;

/**
 * @Author CaptainBing
 * @Date 2024/9/6 11:36
 * @Description 代码沙箱
 */
public interface CodeSandbox {

    /**
     * 执行代码
     * @param executeCodeRequest
     * @return
     */
    ExecuteCodeResponse executeCode(ExecuteCodeRequest executeCodeRequest);

    /**
     * 获取代码沙箱执行器
     * @param mode
     * @return
     */
    static CodeSandbox newInstance(CodeSandboxProperties.CodeSandboxMode mode){
        if (mode == CodeSandboxProperties.CodeSandboxMode.DOCKER){
            return new AcmDockerCodeSandbox();
        }
        return new AcmLocalCodeSandbox();

    }

}
